Problem 2

Part a

I would conclude a is a MA(1), \(\Psi = 0.5\). First, the time-series plot shows it the DGP quickly mean reverting. According to the decomposition model there’s no clear seasonal pattern or trend. Looking at the ACF there’s no geometric decline as would be expected. I used arima.sim to simulate a MA(1), \(\Psi = 0.5\) process and the result is similar in its temporal structure though the precise shocks and levels over time differ.

#pull time-series a
let <- "a"
ts_test <- ts(prob2[[let]], frequency = 12)

#time-series plot
autoplot(ts_test) +
  theme_minimal()

#decomposition model
autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

#ACF
ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

#PACF
ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

#plot simulated ts: MA(1), psi = .5, T=100
autoplot(arima.sim(list(order = c(0, 0, 1), ma = 0.5), n = 100)) 

Part b

There appears to be a seasonal pattern looking at the time-series plot. Decomposing the time-series into its seasonal component shows that the end of each year spikes to high levels, and then reverts back to a very small/negligble seasonal effect. Plotting the ACF before removing the additive seasonal means shows a spike in autocorrelation at lag 12, corresponding to the same month of the last year. After removing the seasonal average from each observation, the ACF shows no substantial autocorrelation.

#pull time-series b
let <- "b"
ts_test <- ts(prob2[[let]], frequency = 12)

#plot time-series
autoplot(ts_test) +
  theme_minimal()

#plot decomposition model
autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

#plot unadjusted ACF
ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

#store decomposition model
decomp <- decompose(ts_test, type = "additive")

#seasonally adjust (y - seasonal mean for y)
ts_test <- ts_test - decomp$seasonal

#plot adjusted ACF
ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part c

There appears to be a deterministic trend according to the time-series plot and decomposition model. The ACF has some semblance to an AR process, albeit without a clearly geometric decline in autocorrelation as might be expected. Detrending the data using a linear model shows that the removing deterministic trend explains away the early trappings of autoregression (i.e. the detrended time-series looks like white noise, ACF has no structure).

#pull time-series c
let <- "c"
ts_test <- ts(prob2[[let]], frequency = 12)

#plot time-series
autoplot(ts_test) +
  theme_minimal()

#plot decomposition model
autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

#plot observed time-series 
ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

#looks like trend, let's estimate the monthly trend
time <- 1:100
lm_c <- lm(ts_test ~ time)
#summary(lm_c) #about .03 increase per month

#subtract estimated trend from time-series
ts_test <- ts_test - lm_c$coefficients[2]*time

#plot de-trended series
autoplot(ts_test) +
  labs(title = "De-trended time-series C") +
  theme_minimal()

#plot de-trended ACF
ggAcf(ts_test) + 
  labs(title = "De-trended ACF for time-series C") +
  theme_minimal() + 
  labs(title = "")

Part d

let <- "d"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part e

let <- "e"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part f

let <- "f"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part g

let <- "g"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part h

let <- "h"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part i

let <- "i"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part j

let <- "j"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part k

let <- "k"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part l

let <- "l"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part m

let <- "m"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part n

let <- "n"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part o

let <- "o"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part p

let <- "p"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part q

let <- "q"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

Part r

let <- "r"

ts_test <- ts(prob2[[let]], frequency = 12)

autoplot(ts_test) +
  theme_minimal()

autoplot(decompose(ts_test, type = "additive")) + 
  theme_minimal()

ggAcf(ts_test) + 
  theme_minimal() + 
  labs(title = "")

ggPacf(ts_test) + 
  theme_minimal() + 
  labs(title = "")